{extend name="public:layout" /}

{block name="title"}
    <title>{:site('siteName')}-XXXX</title>
{/block}

{block name="css"}
    <style>
        .sell-tab { height: 40px; border-bottom: 1px solid #e2e2e2 }
        .sell-tab li { width: 50%; float: left; text-align: center; line-height: 40px; }
        .sell-tab .this { color: #009688; border-bottom: 3px solid #5FB878; margin-bottom: -3px;}
        .ah p { height: 41px; }
    </style>
{/block}

{block name="content"}
    <ul class="sell-tab">
        <li><a href="/recharge/orders">接单列表</a></li>
        <li class="this">我的接单</li>
    </ul>
    <div class="account_li ah">
        <ul>
            {volist name="list" id="v"}
            <li>
                <p><span>超时时间</span><br />{:date('m-d H:i:s',$v['timeout'])}</p>
                <p><span>支付金额</span><br />{$v['money']}</p>
                <p><span>用户名</span><br />{$v['username']}</p>
                <p>
                    <span>联系方式</span> <br />
                    <button class="layui-btn layui-btn-mini layui-btn-normal see" data-msg="姓名：{$v.realname}<br>手机：{$v.mobile}<br>Q Q：{$v.qq}<br>微信：{$v.wechat}<br>邮箱：{$v.email}">查看</button>
                </p>
                <p>
                    <span>支付信息</span><br />
                    <button class="layui-btn layui-btn-mini layui-btn-normal see" data-msg="姓名：{$v.realname}<br>支付宝：{$v.alipay}<br>开户行：{$v.bank}<br>卡号：{$v.bank_card}">查看</button>
                </p>
                <p><span>备注</span><br />{$v.note|default="无"}</p>
                <p>
                    <span>状态</span><br />
                    {eq name="v.status" value="1"}已接单{/eq}
                    {eq name="v.status" value="2"}已支付{/eq}
                    {eq name="v.status" value="3"}已完成{/eq}
                    {eq name="v.status" value="4"}已撤销{/eq}
                </p>
                <p>
                    <span>操作</span><br />
                    {eq name="v.status" value="1"}
                        <button class="layui-btn layui-btn-mini layui-btn-main pay" sell_id="{$v.id}">确认支付</button>
                        <button class="layui-btn layui-btn-mini layui-btn-danger cancel" sell_id="{$v.id}">取消订单</button>
                    {/eq}
                </p>
            </li>
            {/volist}
            <div class="page">
                {$list->render()}
            </div>
        </ul>
    </div>
{/block}

{block name="script"}
    <script type="text/javascript">
        layui.use(['form','layer'], function(){
            var $ = layui.jquery;
            var form = layui.form();
            var layer = layui.layer;
            //取消订单
            $('.cancel').click(function() {
                var sell_id = $(this).attr('sell_id');
                var penalty = "{:config('currency')['cancelPunish']}";
                checkPwd(function(pwd){
                    layer.confirm('取消订单将扣除'+penalty+'违约金，确定？', {
                        btn: ['确定', '取消'],
                        icon: 3
                    }, function(index) {
                        layer.close(index);
                        $.post('{:url("index/sell/cancelOrder")}', {id: sell_id,pwd:pwd}, function(res) {
                            if(res.success == 1){
                                layer.msg(res.msg, {
                                    time: 1000
                                }, function() {
                                    if(res.url){
                                        location.href = res.url.replace('\\');
                                    }else{
                                        location.reload();
                                    }
                                });
                            }else{
                                layer.msg(res.msg);
                            }
                        });
                    });
                });
                return false;
            });
            //确认支付
            $('.pay').click(function(){
                var sell_id = $(this).attr('sell_id');
                checkPwd(function(pwd){
                    layer.confirm('确定已经支付完成', {
                        btn: ['确定', '取消'],
                        icon: 3
                    }, function(index) {
                        layer.close(index);
                        $.post('{:url("index/sell/confirmPay")}', {id: sell_id,pwd:pwd}, function(res) {
                            if(res.success == 1){
                                layer.msg(res.msg, {
                                    time: 1000
                                }, function() {
                                    if(res.url){
                                        location.href = res.url.replace('\\');
                                    }else{
                                        location.reload();
                                    }
                                });
                            }else{
                                layer.msg(res.msg);
                            }
                        });
                    });
                });
            });
            //查看
            $('.see').click(function() {
                var msg = $(this).data('msg');
                layer.open({
                    type: 1,
                    shade: false,
                    title: false,
                    content: '<div style="background: #5FB878;padding: 15px;color: #fff;border-radius: 3px;">' + msg + '</div>'
                });

            });

        });
    </script>
{/block}